package com.bwie.sync;

import com.bwie.common.domain.ChargingStation;
import com.bwie.common.redis.RedisCache;
import com.bwie.mapper.ChargingMapper;
import com.bwie.service.ChargingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.sync
 * @Project：zg6_yuekao
 * @name：VehicleSync
 * @Date：2024/5/17 16:58
 */
@Component
public class VehicleSync {
    @Autowired
    private ChargingService chargingService;
    @Autowired
    private ChargingMapper chargingMapper;
    @Autowired
    private RedisCache redisCache;
    //项目启动 redis存储类型字典值
    @Scheduled(cron = "0/5 * * * * ?")
    public void chargingSync(){
        List<ChargingStation> chargingStationList = chargingMapper.selectChargingList();

        for (ChargingStation chargingStation : chargingStationList) {
            redisCache.setCacheObject("type",chargingStation.getTypeId());
        }
    }
}
